package com.weaver.qfengx.entity;

import org.apache.commons.fileupload.FileItem;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

/**
 * form表单提交的包装类
 */
public class FormFileItem {

    private String fileName;
    private String contentType;
    private File tmpFile;
    private InputStream inputStream;
    private byte[] bytes;

    public FormFileItem(FileItem fileItem) {
        this.fileName = fileItem.getFieldName();
        this.contentType = fileItem.getContentType();
        try {
            this.inputStream = fileItem.getInputStream();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        this.bytes = fileItem.get();
    }

    public String getFileName() {
        return fileName;
    }

    public String getContentType() {
        return contentType;
    }

    public File getTmpFile() {
        return tmpFile;
    }

    public InputStream getInputStream() {
        return inputStream;
    }

    public byte[] getBytes() {
        return bytes;
    }
}
